/*FORM validation and div changing*/
$(document).ready(function() {
						   
	$('#result').hide();
	
	$("#submit").click(function() {
	var username = $("input#username").val();
	var password = $("input#password").val();
		if(username==""){ 
			$("input#username").focus();
			$('#result').fadeIn('slow');
			$(".result-inner").html('Enter the username!');
		  return false;
		}
		if(password==""){ 
			$("input#password").focus();
			$('#result').fadeIn('slow');
			$(".result-inner").html('Enter the password!');
		  return false;
		}
    })

$("form#loginForm").submit(function() {
	var username = $("input#username").val();
	var password = $("input#password").val();									
	var rememberme='';
	if ($('#rememberme').is(':checked'))
		rememberme='on';
	else
		rememberme='off';
	$.ajax({
		url:'login.php',
		type:'post',
		data: "username="+username+"&password="+password+"&rememberme="+rememberme,
		success: function(msg){
			if (msg==0)
			{			
				$('#result').fadeIn('slow');
				$(".result-inner").html('<div class="forgott_pass">Login information incorrect! <a href="#" title="Forgot password"> Forgot password? </a></div>');
			}
			if (msg==1)
			$('#result').hide();
		}
	});
	return false;
});
});
